package com.eostoken.eos_wallet.ui.adapter;

import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.eostoken.eos_wallet.R;
import com.eostoken.eos_wallet.bean.AppsItemBean;
import com.qmuiteam.qmui.layout.QMUILinearLayout;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class AppsAdapter extends BaseQuickAdapter<AppsItemBean, BaseViewHolder> {
    private int mRadius;

    public AppsAdapter(@Nullable List<AppsItemBean> data) {
        super(R.layout.apps_item, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, AppsItemBean appsItemBean) {
        QMUILinearLayout appsItemLayout = baseViewHolder.getView(R.id.appsItemLayout);
        AppCompatImageView smallIconIv = baseViewHolder.getView(R.id.smallIconIv);
        AppCompatTextView titleTv = baseViewHolder.getView(R.id.titleTv);
        AppCompatTextView detailsTitleTv = baseViewHolder.getView(R.id.detailsTitleTv);
        AppCompatImageView bigIconIv = baseViewHolder.getView(R.id.bigIconIv);
        AppCompatTextView nameTv = baseViewHolder.getView(R.id.nameTv);
        AppCompatTextView detailsNameTv = baseViewHolder.getView(R.id.detailsNameTv);

        mRadius = QMUIDisplayHelper.dp2px(getContext(), 8);
        appsItemLayout.setRadius(mRadius);
        Glide.with(getContext()).load(appsItemBean.getSmallImg()).into(smallIconIv);
        titleTv.setText(appsItemBean.getTitle());
        detailsTitleTv.setText(appsItemBean.getDetailsTitle());
        Glide.with(getContext()).load(appsItemBean.getBigImg()).into(bigIconIv);
        nameTv.setText(appsItemBean.getName());
        detailsNameTv.setText(appsItemBean.getDetailsName());
    }
}
